<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:cc="http://xmlns.jcp.org/jsf/composite" 
    xmlns:h = "http://xmlns.jcp.org/jsf/html" 
    xmlns:p="http://primefaces.org/ui">
    <cc:interface 
        rendered = "true" >
        <cc:attribute 
            name = "componentToUpdateAfterOk"
            required="false"
            type = "java.lang.String" />
        <cc:attribute 
            name = "userAnagraphicViewBean" 
            required="true"
            type ="assisisw.smartcal.webuisubsystem.managedbean.AbstractUserAnagraphicsViewBean" />
        <cc:attribute 
            name = "usernameEditable"
            required="true"
            type = "java.lang.Boolean" />
        <cc:attribute 
            name = "userNameValidator"
            required = "true" 
            type = "javax.faces.validator.Validator" /> 
        <cc:attribute
            name = "widgetVarName"
            required ="false"
            type=  "java.lang.String" />
    </cc:interface>
    <cc:implementation 
        rendered = "true" >
        <h:form 
            id = "registrationValidation" 
            rendered = "true" 
            prependId = "false" >
            <p:panel id = "mandatoryFieldsBox" >
                <p:outputLabel 
                    for = "userNameField" 
                    id="userNameLabel" 
                    rendered = "true" 
                    transient = "true"
                    value="Username ( e-mail ) :" />
                <p:inputText 
                    id = "userNameField" 
                    immediate="true"
                    maxlength = "20"
                    readonly="#{!cc.attrs.usernameEditable}"
                    rendered = "true" 
                    validator = "#{cc.attrs.userNameValidator.validate }" 
                    value="#{cc.attrs.userAnagraphicViewBean.userSigningUp.mail}" />
                <p:outputLabel 
                    for = "passwordField"
                    id = "passwordLabel" 
                    rendered = "true" 
                    transient="true"
                    value="Password :" />
                <p:inputText 
                    autocomplete = "off"
                    disabled = "false"
                    id = "passwordField"
                    immediate = "true" 
                    label = "Password:" 
                    maxlength = "20"
                    placeholder = "password" 
                    readonly = "false"  
                    rendered = "true" 
                    requiredMessage = "Password Required !"
                    type="password"
                    validator = "#{passwordValidator.validate }"
                    value = "#{cc.attrs.userAnagraphicViewBean.userSigningUp.password}" 
                    widgetVar = "passwordField" />
            </p:panel>
            <p:panel id = "nonManadatoryFieldsBox">
                <p:outputLabel 
                    for = "firstNameField"
                    id = "firstNameLabel" 
                    rendered = "#{userAnagraphicsBean.detailViewEnabled}" 
                    value = "First Name :"/>
                <p:inputText 
                    id = "firstNameField" 
                    maxlength = "15"
                    rendered = "#{userAnagraphicsBean.detailViewEnabled}" 
                    value = "#{cc.attrs.userAnagraphicViewBean.userSigningUp.firstname}" />
                <p:outputLabel 
                    for = "lastNameField"
                    id = "lastNameLabel" 
                    rendered= "#{userAnagraphicsBean.detailViewEnabled}" 
                    value = "Last Name :" />
                <p:inputText 
                    id = "lastNameField" 
                    maxlength = "15"
                    rendered = "#{userAnagraphicsBean.detailViewEnabled}" 
                    value="#{cc.attrs.userAnagraphicViewBean.userSigningUp.lastname}"/>
                <p:commandButton
                    id = "provideMoreDetailButton" 
                    rendered="true" 
                    validateClient="false"
                    type="button"
                    value = "#{userAnagraphicsBean.detailsButtonString}" >
                    <p:ajax 
                        async="true" 
                        disabled="false"
                        event="click" 
                        immediate="true" 
                        listener="#{userAnagraphicsBean.toggleDetailViewEnabled ()}"
                        rendered="true"
                        partialSubmit="true"
                        process="provideMoreDetailButton"
                        update="nonManadatoryFieldsBox" /> 
                </p:commandButton>
            </p:panel>
            <p:commandButton 
                action="#{cc.attrs.userAnagraphicViewBean.submitUserAnagraphicForm()}"
                disabled = "false" 
                id = "signUpButton" 
                rendered = "true" 
                type="submit"
                validateClient = "true"
                value = "Done !" >
            </p:commandButton>
            <p:growl 
                autoUpdate="true" 
                id ="userViewGrowl" 
                showDetail="true" 
                showSummary="true"
                sticky="false" 
                widgetVar="userViewGrowl" />       
        </h:form>
    </cc:implementation>
</html>